import request from '@/utils/request'
import { getToken } from '@/utils/auth'

export function getAllOrders() {
  return request({
    url: '/orders/all',
    method: 'get'
  })
}

export function getOrderById(id) {
  return request({
    url: '/orders/order',
    method: 'get',
    params: {
      orderId: id
    }
  })
}

export function getOrdersByOrg() {
  return request({
    url: '/orders/org',
    method: 'get',
    params: {
      head: getToken()
    }
  })
}

export function getOrdersByCampus() {
  return request({
    url: '/orders/cam',
    method: 'get',
    params: {
      head: getToken()
    }
  })
}

export function getOrdersByReference() {
  return request({
    url: '/orders/reference',
    method: 'get',
    params: {
      reference: getToken()
    }
  })
}

export function conditionSearch(search) {
  return request({
    url: '/orders/mohu/condition/search',
    method: 'post',
    data: {
      campusName: search.campusName,
      lessonId: search.lessonId,
      orgName: search.orgName,
      payType: search.payType,
      userName: search.userName,
      maxprice: search.maxPrice,
      minprice: search.minPrice
    }
  })
}

export function conditionSearch2(search) {
  return request({
    url: '/orders/mohu/condition/search',
    method: 'post',
    data: {
      campusName: search.campusName,
      lessonId: search.lessonId,
      orgName: search.orgName,
      payType: search.payType,
      userName: search.userName,
      maxprice: search.maxPrice,
      minprice: search.minPrice,
      orgHead: getToken()
    }
  })
}

export function conditionSearch3(search) {
  return request({
    url: '/orders/mohu/condition/search',
    method: 'post',
    data: {
      campusName: search.campusName,
      lessonId: search.lessonId,
      orgName: search.orgName,
      payType: search.payType,
      userName: search.userName,
      maxprice: search.maxPrice,
      minprice: search.minPrice,
      campushead: getToken()
    }
  })
}

export function conditionSearch4(search) {
  return request({
    url: '/orders/mohu/condition/search',
    method: 'post',
    data: {
      campusName: search.campusName,
      lessonId: search.lessonId,
      orgName: search.orgName,
      payType: search.payType,
      userName: search.userName,
      maxprice: search.maxPrice,
      minprice: search.minPrice,
      referenceId: getToken()
    }
  })
}

export function mohuSearch(str) {
  return request({
    url: '/orders/order/search2',
    method: 'post',
    data: {
      str: str,
      userId: getToken()
    }
  })
}

